package junit;

import base.Identifier;
import base.Interpreter;
import expressions.*;
import instructions.*;
import values.Integer;

public class TestOp {

	/* Operations tests :
	 * 	x=4;
	 * 	y=2;
	 * 	print(x+y);
	 * 	print(x-y);
	 * 	print(x*y);
	 * 	print(x/y);
	 */
	
	public static void main(String[] args) {
		
		Identifier x = new Identifier("x");
		Identifier y = new Identifier("y");
		
		VariableAssign xVal = new VariableAssign(x, new Integer(4));
		VariableAssign yVal = new VariableAssign(y, new Integer(2));
		
		Add add = new Add(new VariableAccess(x), new VariableAccess(y));
		Substract sub = new Substract(new VariableAccess(x), new VariableAccess(y));
		Multiply mult = new Multiply(new VariableAccess(x), new VariableAccess(y));
		Divide div = new Divide(new VariableAccess(x), new VariableAccess(y));
		Modulo mod = new Modulo(new VariableAccess(x), new VariableAccess(y));
		
		Print addPrint = new Print(add);
		Print subPrint = new Print(sub);
		Print multPrint = new Print(mult);
		Print divPrint = new Print(div);
		Print modPrint = new Print(mod);
		
		Composition compoVal = new Composition(xVal, yVal);
		Composition compoAdd = new Composition(compoVal, addPrint);
		Composition compoSub = new Composition(compoVal, subPrint);
		Composition compoMult = new Composition(compoVal, multPrint);
		Composition compoDiv = new Composition(compoVal, divPrint);
		Composition compoMod = new Composition(compoVal, modPrint);
		
		System.out.println("Tests on Operations : x = 4 and y = 2");
		System.out.println("Test 1 : x + y");
		Interpreter.instr(compoAdd);
		System.out.println("Test 2 : x - y");
		Interpreter.instr(compoSub);
		System.out.println("Test 3 : x * y");
		Interpreter.instr(compoMult);
		System.out.println("Test 4 : x / y");
		Interpreter.instr(compoDiv);
		System.out.println("Test 5 : x % y");
		Interpreter.instr(compoMod);
		
		
		
	}
}
